/*
 * quantity.h
 *
 *  Created on: Mar 12, 2015
 *      Author: silivas
 */

#ifndef QUANTITY_H_
#define QUANTITY_H_
#include "base_type.h"
#include <string>
using namespace std;
template<class UNIT>
class Quantity {
public:
	Quantity(Amount val, UNIT& a) :
			_val(val), _unit(a) {
	}

	bool operator ==(const Quantity<UNIT>& rhs) const {
		return toBaseUnit() == (rhs.toBaseUnit());
	}

	bool operator !=(const Quantity<UNIT>& rhs) const {
		return !(*this == rhs);
	}

	Quantity operator +(const Quantity<UNIT>& rhs) {
		return Quantity<UNIT>(toBaseUnit() + rhs.toBaseUnit(), UNIT::getBASE());
	}

	string toStr(){
		return _unit.toStr(_val);
	}

protected:
	Amount toBaseUnit() const {
		return _val * _unit.BaseUnit();
	}
	Amount _val;
	UNIT& _unit;
};

//typedef Quantity<VolUnit> Vol;
#endif /* TEST_LENGTH_H_ */
